|
|
|
|
|
|
|
lpRemoteName field in the structure must be set to the name of the network resource (not the local mapped drive letter). You can set the dwType field to the constant RESOURCETYPE_DISK to improve performance somewhat (the function won't search through nondisk resource types such as printers). The lpProvider field can also be set if you know the network provider who owns the resource. The other fields in the structure are ignored. |
|
|
|
|
|
|
|
|
The lpBuffer parameter takes a pointer to a memory buffer to load with a NETRESOURCE structure followed by any necessary string information. The string pointers in the returned NETRESOURCE structure will point to the strings within this buffer. The lplpSystem parameter will also be set to point to a string within this buffer. |
|
|
|
|
|
|
|
|
The size of the buffer can be determined using the exact same method described in Part 1 of this puzzlethe required buffer size will be loaded into the lpcbBuffer parameter. |
|
|
|
|
|
|
|
|
Confused? Here's one final thought: The win32api.txt file defines the lpLocalName, lpRemoteName, lpComment, and lpProvider fields of the NETRESOURCE structure as strings. |
|
|
|
|
|
|
|
|
This would lead you to the following declaration and code as shown in MapInfo2.vbp project in the Puzzles subdirectory (on the CD that comes with this book): |
|
|
|
|
|
|
|
|
Private Declare Function WNetGetResourceInformation Lib "mpr.dll" _
Alias "WNetGetResourceInformationA" ( lpNetResource As NETRESOURCE, _
lpBuffer As Byte, lpcbBuffer As Long, lplpSystem As Long) As Long
Private Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As String
lpRemoteName As String
lpComment As String
lpProvider As String
End Type
' Get the network provider information
Private Sub GetResourceInfo(resourcename As String)
Dim nr As NETRESOURCE
Dim lpSystem As Long
Dim OutputBufferSize As Long
Dim OutputBuffer() As Byte
Dim res As Long |
|
|
|
|
|